package org.linlinjava.litemall.admin.web2.order.resp;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.linlinjava.litemall.core.util.DateTimeUtil;
import org.linlinjava.litemall.core.util.Util;
import org.linlinjava.litemall.db.domain.TGoods;
import org.linlinjava.litemall.db.domain.TOrder;
import org.linlinjava.litemall.db.domain.TUser2;
import org.linlinjava.litemall.db.enumeration.Const;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 订单详情
 */
@ApiModel
public class OResp7 {

    @ApiModelProperty("id")
    private Integer id;

    @ApiModelProperty("订单编号")
    private String transNo;
    @ApiModelProperty("订单状态")
    private String orderStatus;

    @ApiModelProperty("订单类型")
    private String orderType;
    @ApiModelProperty("支付方式")
    private String payType;

    @ApiModelProperty("下单会员")
    private String memberName;
    @ApiModelProperty("收货人")
    private String nameInfo;

    @ApiModelProperty("下单时间")
    private String createdTime;
    @ApiModelProperty("支付时间")
    private String payTime;

    @ApiModelProperty("发货时间")
    private String sendTime;
    @ApiModelProperty("提货时间")
    private String pickupTime;

    @ApiModelProperty("提货点")
    private String pickupShopInfo;

    @ApiModelProperty("配送到")
    private String sendAddress; //(如果是自提方式 就显示自提）

    @ApiModelProperty("优惠")
    private String couponAmount;

    @ApiModelProperty("配送费")
    private String sendFree;

    @ApiModelProperty("实收款")
    private String realAmount;

    @ApiModelProperty("销售价")
    private String saleAmount;

    @ApiModelProperty("总计")
    private String totalCount;

    @ApiModelProperty("商品项")
    private List<Dto1> items = Util.aList();

    public void pushOrder(TOrder order) {
        if (order != null) {
            this.id = order.getId();
            this.transNo = order.getTransNo();
            this.orderStatus = Const.ORDER_STATUS_TYPE.value(order.getOrderStatus());
            this.orderType = Const.ORDER_TYPE.value(order.getOrderType());
            if (order.getPayType() != null)
                this.payType = Const.ORDER_PAY_TYPE.value(order.getPayType());

            this.nameInfo = order.getHarvesterName() + " " + order.getHarvesterPhone();

            createdTime = order.getCreatedTime().format(DateTimeUtil.format);
            if (order.getPayTime() != null)
                payTime = order.getPayTime().format(DateTimeUtil.format);

            if (order.getSendTime() != null)
                sendTime = order.getSendTime().format(DateTimeUtil.format);
            if (order.getPickupTime() != null)
                pickupTime = order.getPickupTime().format(DateTimeUtil.format);

            if (order.getSendType() == Const.SEND_TYPE.SELF_MENTION) {
                sendAddress = "自提";
            } else {
                sendAddress = order.getTargetAddress();
            }

            if (order.getSendFree() != null)
                sendFree = order.getSendFree().toString();
            if (order.getPayAmount() != null)
                realAmount = order.getPayAmount().toString();

            if (order.getSaleAmount() != null)
                saleAmount = order.getSaleAmount().toString();
        }
    }


    public List<Dto1> getItems() {
        return items;
    }

    public void setItems(List<Dto1> items) {
        this.items = items;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTransNo() {
        return transNo;
    }

    public void setTransNo(String transNo) {
        this.transNo = transNo;
    }

    public String getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(String orderStatus) {
        this.orderStatus = orderStatus;
    }

    public String getOrderType() {
        return orderType;
    }

    public void setOrderType(String orderType) {
        this.orderType = orderType;
    }

    public String getPayType() {
        return payType;
    }

    public void setPayType(String payType) {
        this.payType = payType;
    }

    public String getMemberName() {
        return memberName;
    }

    public void setMemberName(String memberName) {
        this.memberName = memberName;
    }

    public String getNameInfo() {
        return nameInfo;
    }

    public void setNameInfo(String nameInfo) {
        this.nameInfo = nameInfo;
    }

    public String getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(String createdTime) {
        this.createdTime = createdTime;
    }

    public String getPayTime() {
        return payTime;
    }

    public void setPayTime(String payTime) {
        this.payTime = payTime;
    }

    public String getSendTime() {
        return sendTime;
    }

    public void setSendTime(String sendTime) {
        this.sendTime = sendTime;
    }

    public String getPickupTime() {
        return pickupTime;
    }

    public void setPickupTime(String pickupTime) {
        this.pickupTime = pickupTime;
    }

    public String getPickupShopInfo() {
        return pickupShopInfo;
    }

    public void setPickupShopInfo(String pickupShopInfo) {
        this.pickupShopInfo = pickupShopInfo;
    }

    public String getSendAddress() {
        return sendAddress;
    }

    public void setSendAddress(String sendAddress) {
        this.sendAddress = sendAddress;
    }

    public String getCouponAmount() {
        return couponAmount;
    }

    public void setCouponAmount(String couponAmount) {
        this.couponAmount = couponAmount;
    }

    public String getSendFree() {
        return sendFree;
    }

    public void setSendFree(String sendFree) {
        this.sendFree = sendFree;
    }

    public String getRealAmount() {
        return realAmount;
    }

    public void setRealAmount(String realAmount) {
        this.realAmount = realAmount;
    }

    public String getSaleAmount() {
        return saleAmount;
    }

    public void setSaleAmount(String saleAmount) {
        this.saleAmount = saleAmount;
    }

    public String getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(String totalCount) {
        this.totalCount = totalCount;
    }
}
